#include "mainwindow.h"
#include "ui_mainwindow.h"


MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}


#include <QSettings>
#include <QString>
#include <QDebug>

void Writeinitfile()
{
    QSettings *ConfigWriteInitFile=new QSettings("MySQLFile.ini",QSettings::IniFormat);

    //向INI文件当中写入数据信息
    //第一节的第一个参数，后面就依次类推
    ConfigWriteInitFile->setValue("/datebase/ip","192.168.0.12");
    ConfigWriteInitFile->setValue("/database/port","3308");
    ConfigWriteInitFile->setValue("/database/user","root");
    ConfigWriteInitFile->setValue("/datebase/password","sheng2858");

    ConfigWriteInitFile->setValue("/notice/version","5.6");

    qDebug()<<"write success";
    //向IN文件写入后，删除指针
    delete ConfigWriteInitFile;
}
void Readinitfile()
{
    QSettings *ConfigReadIniFiles=new QSettings("MySQLFile.ini",QSettings::IniFormat);
    QString strip=ConfigReadIniFiles->value("/datebase/ip").toString();
    QString strport=ConfigReadIniFiles->value("/database/port").toString();
    QString struser=ConfigReadIniFiles->value("database/user").toString();
    QString strpassword=ConfigReadIniFiles->value("/database").toString();

    delete ConfigReadIniFiles;

}
void ReaIniFileKey()
{
      QSettings settings("MySQLFile.ini",QSettings::IniFormat);
      foreach(QString key,settings.allKeys())
      {
          qDebug()<<key<<","<<settings.value(key).toString().toUtf8().data();
      }

}
